﻿@{
    ViewBag.Title = "RptPosDay";
}

@section scripts
{ 
    <script src="@Url.Content("~/Scripts/shared/share.js")" type="text/javascript"></script> 
    <script src="@Url.Content("~/Scripts/shared/shown.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/common/gridlayout.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/common/export.js")" type="text/javascript"></script>
}
    @Html.Partial("~/Views/Modular/ReportsToolbar.cshtml")
<form id="form1">
    <div id = "DivHeader">
        <table style="margin-bottom:4px;">
            <tr>
                <td width ="70px" align="right">日期范围：</td>
                <td width ="310px">
                    @Html.Partial("~/Views/Modular/dxDateRange.cshtml") 
                </td>
                <td width ="70px" align="right">门店名称：</td>
                <td width ="190px">    
                    @Html.Partial("~/Views/Modular/LookupStockInfo.cshtml")                      
                </td>
           </tr>
        </table>
    </div>
</form>
        <div class="mini-fit" >
            <div id="datagrid1" class="mini-datagrid" style="width:100%;height:100%;" pageSize="15"
                    borderStyle="border:1;" url="../Report/GetBillDetail"  showSummaryRow="true"
                    allowCellSelect="true" allowCellEdit="true"showColumnsMenu="false"fitColumns="false" 
                    sortMode="client" ondrawsummarycell="onDrawSummaryCell">
                <div property="columns">
                    <div type="checkcolumn" >选行</div>
                    <div type="indexcolumn" width="40" headerAlign="center" >序号</div>
                    <div field="FNumber" name="FNumber" width="80" headeralign="center" allowsort="true">门店编号</div>
                    <div field="FName" name="FName" width="100" headeralign="center" allowsort="true">门店名称</div>
                    <div header="零售合计" headeralign="center">
                        <div property="columns">
                            <div field="FPos_Count" name="FPos_Count" width="80" headerAlign="center"align="right">客单数</div>
                            <div field="FPos_Qty" name="FPos_Qty" width="70" headeralign="center" allowsort="true" align="right" numberFormat="#,0.00">数量</div>                            
                            <div field="FPos_RealAmount" name="FPos_RealAmount" width="80" headeralign="center" allowsort="true" align="right" numberFormat="#,0.00">金额</div>
                            <div field="FPos_CostAmount" name="FPos_CostAmount" width="80" headeralign="center" allowsort="true"align="right" numberFormat="#,0.00">成本</div>
                            <div field="FPos_Profit" name="FPos_Profit" width="80" headeralign="center" allowsort="true" align="right" numberFormat="#,0.00">毛利</div>                               
                        </div>
                    </div>
                    <div header="会员充值合计" headeralign="center">
                        <div property="columns">                              
                            <div field="FRec_Count" name="FRec_Count" width="80" headerAlign="center"align="right">充值笔数</div>
                            <div field="FPos_MemberAmt" name="FPos_MemberAmt" width="80" headerAlign="center"align="right"numberFormat="#,0.00">会员充值</div>
                            <div field="FPos_TimeAmt" name="FPos_TimeAmt" width="80" headerAlign="center"align="right"numberFormat="#,0.00">次卡充值</div>
                            <div field="FPos_MtAmtAll" name="FPos_MtAmtAll" width="80" headerAlign="center"align="right"numberFormat="#,0.00">合计充值</div>                            
                        </div>
                    </div>
                    <div header="批发合计" headeralign="center">
                        <div property="columns">
                            <div field="FSel_Count" name="FSel_Count" width="80" headerAlign="center"align="right">订单笔数</div>
                            <div field="FSel_Qty" name="FSel_Qty" width="70" headeralign="center" allowsort="true" align="right" numberFormat="#,0.00">数量</div>                            
                            <div field="FSel_RealAmount" name="FSel_RealAmount" width="80" headeralign="center" allowsort="true" align="right" numberFormat="#,0.00">金额</div>
                            <div field="FSel_CostAmount" name="FSel_CostAmount" width="80" headeralign="center" allowsort="true"align="right" numberFormat="#,0.00">成本</div>
                            <div field="FSel_Profit" name="FSel_Profit" width="80" headeralign="center" allowsort="true" align="right" numberFormat="#,0.00">毛利</div>
                        </div>
                    </div>
                    <div header="总计" headeralign="center">
                        <div property="columns">
                            <div field="FAll_Count" name="FMall_Count" width="80" headerAlign="center"align="right">合计笔数</div>
                            <div field="FAll_Qty" name="FAll_Qty" width="70" headeralign="center" allowsort="true" align="right" numberFormat="#,0.00">数量</div>                            
                            <div field="FAll_RealAmount" name="FAll_RealAmount" width="80" headeralign="center" allowsort="true" align="right" numberFormat="#,0.00">金额</div>
                            <div field="FAll_CostAmount" name="FAll_CostAmount" width="80" headeralign="center" allowsort="true"align="right" numberFormat="#,0.00">成本</div>
                            <div field="FAll_Profit" name="FAll_Profit" width="80" headeralign="center" allowsort="true" align="right" numberFormat="#,0.00">毛利</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
<script>
    var sumFields = "FPos_Qty,FPos_RealAmount,FPos_CostAmount,FPos_Profit,FPos_MemberAmt,FPos_TimeAmt,FPos_MtAmtAll,FPos_AmtAll,"
        + "FSel_Qty,FSel_RealAmount,FSel_CostAmount,FSel_Profit,FAll_Qty,FAll_RealAmount,FAll_CostAmount,FAll_Profit";
    function FormShown() {
        mini.parse();
        var toDay = new Date();
        mini.getbyName("FDate1").setValue(toDay);
        mini.getbyName("FDate2").setValue(toDay);
        clearloca();
        LoadData();
    }
    
    //加载资料列表
    function LoadData() {
        var sSystemAppID = parent.window.getSystemAppID();
        var cDateTime1 = mini.getbyName("FDate1").getFormValue();
        var cDateTime2 = mini.getbyName("FDate2").getFormValue();
        var mStockID = mini.getbyName("FStockID").getValue();

        var json = "[{";
        json = json + '"mListType":"' + '24",';//列表类型
        json = json + '"mSystemAppID":"' + sSystemAppID + '",';
        json = json + '"mDate1":' + '"' + cDateTime1 + '",';
        json = json + '"mDate2":' + '"' + cDateTime2 + '",';
        json = json + '"mStockID":' + '"' + mStockID + '"';
        json = json + "}]";
        var grid = mini.get("datagrid1");
        grid.load({ mydata: json });

        mExportDataUrl = grid.url;
        mExportDataJson = json;//导出
    }

    function search() {
        LoadData();

    }
    function printdata() {
        var grid = mini.get("datagrid1");
        var url = "../Report/PrintReport";
        mini.open({
            url: url,
            title: "打印", width: 1000, height: 700,
            onload: function () {
                var iframe = this.getIFrameEl();
                var NoneDisplayCol = [0];
                iframe.contentWindow.InitalPrint(grid, NoneDisplayCol, parent.window.getSystemCompany() + "门店综合分析报表");
            }
        });
    }

    function clearloca() {
        mini.getbyName("FStockID").setValue("");
        mini.getbyName("FStockID").setText("");
        mini.getbyName("FStockName").setValue("");
        var nowDate = new Date();
        mini.getbyName("FDate1").setValue(nowDate);
        mini.getbyName("FDate2").setValue(nowDate);
    }

</script>



